var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    page: 0
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    let extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {};
    const token = extConfig.appid;
    app.ihttpGet("https://www.58zltc.com/api.php/Credit/getshopGoods/shop_id/" + options.shop_id + '/page/' + that.data.page, res=>{
      that.setData({
        list: res.data,
        shop_id: options.shop_id
      })
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    console.log(123)
    var that = this
    var list = that.data.list
    var page = that.data.page + 1
    app.ihttpGet("https://www.58zltc.com/api.php/Credit/getCateGoods/id/" + that.data.cate_id + '/page/' + page, res => {
      var d = res.data
      for (var index in d.goods) {
        list.goods.push(d.goods[index])
      }
      that.setData({
        list: list,
        page: page
      })
    })
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  },
  backto: function () {
    wx.navigateBack({})
  },
  jump: function (e) {
    var url = e.currentTarget.dataset.url
    wx.navigateTo({
      url: url,
    })
  }
})